package net.stuffrepos.bricknetcenter.util.gui.inputcomponent;

import javax.swing.JComboBox;
import net.stuffrepos.bricknetcenter.util.gui.inputcomponent.InputComponentValueParser.ValueResult;

/**
 *
 * @author Eduardo H. Bogoni <eduardobogoni@gmail.com>
 */
public class ComboBoxEnumParser implements InputComponentValueParser<JComboBox, Enum> {

    @Override
    public ValueResult<Enum> fromComponent(JComboBox component) {
        return new ValueResult<Enum>((Enum) component.getSelectedItem(), true);
    }

    @Override
    public void toComponent(JComboBox component, Enum value) {
        component.setSelectedItem(value);
    }

    @Override
    public void setEditable(JComboBox component, boolean editable) {
        component.setEditable(editable);
    }
}
